package com.njtoyo.taxi.admin.handler.rule.online_valuation.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.LocalTime;

@Data
public class TimePeriod {
    @JsonFormat(pattern = "HH:mm")
    private LocalTime startTime;

    @JsonFormat(pattern = "HH:mm")
    private LocalTime endTime;

    // 检查目标时间是否在区间内
    public boolean contains(LocalTime target) {
        if (startTime.isBefore(endTime) || startTime.equals(endTime)) {
            return !target.isBefore(startTime) && !target.isAfter(endTime);
        } else { // 处理跨夜时段
            return !target.isBefore(startTime) || !target.isAfter(endTime);
        }
    }
}
